﻿using Common.Cache;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace Common.Web
{
    /*
     临时兼容性代码，待所有端口都切换为新版token后即可删除此代码
     */
    internal class xTokenHelper
    {
        private static ICache memory = new MemoryCache();

        public static BaseUserDTO Get(string token)
        {
            string key = $"x-token:{token}";
            var user = memory.Get<BaseUserDTO>(key);
            if (user != null)
            {
                return user;
            }

            user = FreeRedisCache.Instance.Get<BaseUserDTO>(key);
            if (user != null)
            {
                memory.Add(key, user, TimeSpan.FromMinutes(10));
            }
            return user;
        }
    }
    internal class BaseUserDTO
    {
        public string UserType { get; set; }
        public string PersonID { get; set; }
        public string MerchantID { get; set; }
        public string OrganizationID { get; set; }        
    }
    internal enum SettleAccountType
    {
        platform = 1,
        isv = 2,
        merchant = 4,
        captain = 8,
        master = 16,
        partner = 32,
        totalplatform = 64,
        customer = 128
    }
}
